<!--管理员发布通知-->
<link rel="stylesheet" type="text/css" href="./css/announce.css" />

<div class="modal-dialog modal fade" id="fabu1">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal">&times;</button>
		</div>
		<div class="modal-body">
			<p>发布成功!点击确认返回到通知页</p>
		</div>
		<div class="modal-footer">
			<button id="ture" type="button" class="btn btn-primary" class="close" data-dismiss="modal">确定</button>
		</div>
	</div>
</div>

<h3 class="text-center">发布通知</h3>
<div class="form-group">
	<label id="biaoti" class="text-left" for="exampleInputEmail1">标题</label>
	<input class="text-left" type="text" class="form-control" id="title" placeholder="在此输入标题">
</div>
<span id="span">权重</span>
<select id="caidan">
	<option>1</option>
	<option>2</option>
	<option>3</option>
	<option>4</option>
	<option>5</option>
	<option>6</option>
	<option>7</option>
	<option>8</option>
	<option>9</option>
	<option>10</option>
</select>
<div id="announce_div">
	<script id="editor" type="text/plain" charset="utf-8" style="width: 100%; height: 360px;"></script>
</div>
<div class="text-right">
	<button type="button" class="btn btn-primary" id="btn_fabu">发布</button>
</div>

<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
		//实例化编辑器
		UE.delEditor('editor');
		//建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
		var ue = UE.getEditor('editor', {
			initialFrameWidth: '100%', //设置编辑器宽度
			scaleEnabled: true, //设置不自动调整高度
			//scaleEnabled {Boolean} [默认值：false]//是否可以拉伸长高，(设置true开启时，自动长高失效)
			toolbars: [
				['toggletool', 'fullscreen', 'source', '|', 'undo', 'redo', '|',
					'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript',
					'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|',
					'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', '|',
					'simpleupload', 'insertimage', '|', 'selectall', 'cleardoc'
				]
			]
		});
	})
</script>

<script>
	$('#btn_fabu').click(function() {
		$('#fabu1').modal({
			keyboard: true,
			show: true
		})
	})
	
	$('#ture').click(function() {
		// $('.ss').addClass('active')
		setTimeout(() => {
			$('.center').html('');
			$('.center').load('./messageamend.html');
		}, 300);
	})

	$('#btn_fabu').click(function() {
		$.ajax({
			xhrFields: {
				withCredentials: true
			},
			type: "POST",
			url: getFullURL("admin/sub-inform"),
			dataType: 'json',
			data: {
				Sid: "xiangsihu",
				title: $('#title').val(),
				content: UE.getEditor('editor').getContent(),
				priority: $("#caidan option:selected").text()
			},
			success: function(data) {
				if(data.status == 0) {
					console.log("发布成功");
				}
			},
			error: function(err) {
				alert("请求异常，请重新登录！", function() {
					$(location).attr('href', './login.html');
				})
			}
		})
	})
</script>